package security;

/**
 *
 * @author MONESI
 */
import boundary.EventManager;
import boundary.NotificationManager;
import boundary.UserManager;
import control.ForecastEngine;
import entity.Event;
import entity.Notification;
import java.io.Serializable;
import java.util.Date;
import javax.ejb.EJB;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;

@Named
@SessionScoped
public class EventBean implements Serializable {
    
    Date d = new Date ();
    
    @EJB
    private NotificationManager nm;

    @EJB
    private EventManager em;
    
    @EJB
    private UserManager um;
    
    Event event;
    
    

    public EventBean() {
    }
    
     public Event getEvent() {
        if (event == null) {
            event = new Event();
        }
        return event;
    }
    
    

    public void setEvent (Event event) {
        this.event = event;
    }
   
    
    public String registerEvent() {
        
        ForecastEngine f= new ForecastEngine ();
        f.weather(event);   
        
        event.setCreator(um.getLoggedUser().getEmail());
        
        
        em.save(event);
                   
        
        
        return "eventpage";
    }
    

}